package com.zbkj.front.controller.assistant;

import com.zbkj.common.model.assistant.AssistantConversation;
import com.zbkj.common.result.CommonResult;
import com.zbkj.common.token.FrontTokenComponent;
import com.zbkj.front.controller.assistant.service.AssistantConversationService;
import com.zbkj.service.assistant.model.request.AssistantConversationInitRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 客服会话表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/front/assistant/conversation")
@Api(tags = "客服-会话表") //配合swagger使用

public class AssistantConversationController {

    @Autowired
    private FrontTokenComponent frontTokenComponent;

    @Autowired
    private AssistantConversationService assistantConversationService;

    @ApiOperation(value = "获取会话")
    @GetMapping("/current")
    public CommonResult<AssistantConversation> current(@ModelAttribute AssistantConversationInitRequest request) {
        Integer userId = frontTokenComponent.getUserId();
        AssistantConversation assistantConversation = assistantConversationService.getUserConversation(request, userId);
        return CommonResult.success(assistantConversation);
    }

//    /**
//     * 分页显示客服会话表
//     * @param request 搜索条件
//     * @param pageParamRequest 分页参数
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "分页列表") //配合swagger使用
//    @RequestMapping(value = "/list", method = RequestMethod.GET)
//    public CommonResult<CommonPage<AssistantConversation>>  getList(@Validated AssistantConversationSearchRequest request, @Validated PageParamRequest pageParamRequest) {
//        CommonPage<AssistantConversation> assistantConversationCommonPage = CommonPage.restPage(assistantConversationService.getList(request, pageParamRequest));
//        return CommonResult.success(assistantConversationCommonPage);
//    }
//
//    /**
//     * 新增客服会话表
//     * @param assistantConversationRequest 新增参数
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "新增")
//    @RequestMapping(value = "/save", method = RequestMethod.POST)
//    public CommonResult<String> save(@RequestBody @Validated AssistantConversationRequest assistantConversationRequest) {
//        AssistantConversation assistantConversation = new AssistantConversation();
//        BeanUtils.copyProperties(assistantConversationRequest, assistantConversation);
//
//        if(assistantConversationService.save(assistantConversation)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }
//
//    /**
//     * 删除客服会话表
//     * @param id Integer
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "删除")
//    @RequestMapping(value = "/delete", method = RequestMethod.GET)
//    public CommonResult<String> delete(@RequestParam(value = "id") Integer id) {
//        if(assistantConversationService.removeById(id)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }
//
//    /**
//     * 修改客服会话表
//     * @param id integer id
//     * @param assistantConversationRequest 修改参数
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "修改")
//    @RequestMapping(value = "/update", method = RequestMethod.POST)
//    public CommonResult<String> update(@RequestParam Integer id, @RequestBody @Validated AssistantConversationRequest assistantConversationRequest) {
//        AssistantConversation assistantConversation = new AssistantConversation();
//        BeanUtils.copyProperties(assistantConversationRequest, assistantConversation);
//        assistantConversation.setId(id);
//
//        if(assistantConversationService.updateById(assistantConversation)) {
//            return CommonResult.success();
//        } else {
//            return CommonResult.failed();
//        }
//    }
//
//    /**
//     * 查询客服会话表信息
//     * @param id Integer
//     * @author keNan
//     * @since 2025-06-11
//     */
//    @ApiOperation(value = "详情")
//    @RequestMapping(value = "/info", method = RequestMethod.GET)
//    public CommonResult<AssistantConversation> info(@RequestParam(value = "id") Integer id) {
//        AssistantConversation assistantConversation = assistantConversationService.getById(id);
//        return CommonResult.success(assistantConversation);
//    }
}



